<?php
// +----------------------------------------------------------------------
// | 幕小铺
// +----------------------------------------------------------------------
// | 版权所有 2016~2020 幕小铺科技（大连）有限公司
// +----------------------------------------------------------------------
// | 2020/03/14
// +----------------------------------------------------------------------

namespace app\user_center\home;
use app\common\controller\AuthCheckByMcn;

/**
 * Mcn模块
 * @package app\admin\controller
 */
class Mcn extends AuthCheckByMcn
{
    /**
     * Mcn-艺人列表
     * @author shiqiang<976162041@qq.com>
     * @return mixed
     */
	public function artist_list(){
		 //参数接收
        $params 			= $this->getParams(0);//0 get 1 post 
        $uid    			= intval(isset($params["user_id"]) ? $params["user_id"] : 0);
        //$attestation_id   	= intval(isset($params["attestation_id"]) ? $params["attestation_id"] : 0);
		
        //数据验证
        $Validate = validate('Mcn', 'validate\mcn');
        if( !$Validate -> scene('artist_list') -> check($params) ){
            json_out(-1001, $Validate -> getError(), []);//验证失败
        }
		
		//逻辑处理
        $list = controller('Mcnlogic', 'logic\mcn') -> artist_list($uid);

         //数据返回
        if($list['code'] == 200){
            json_out(200, '获取成功', (array)$list['data']);      
        }else{
            json_out($list['code'], $list['message'], []);      
        }
    }
    
	/**
     * 添加艺人
     * @author shiqiang<976162041@qq.com>
     * @return mixed
     */
	public function add_artist(){
		 //参数接收
        $params 			= $this->getParams(1);//0 get 1 post 
        $uid    			= intval(isset($params["user_id"]) ? $params["user_id"] : 0);
        //$attestation_id   	= intval(isset($params["attestation_id"]) ? $params["attestation_id"] : 0);
        $artist_mobile   	= intval(isset($params["artist_mobile"]) ? $params["artist_mobile"] : 0);
        $artist_name   		= strval(isset($params["artist_name"]) ? $params["artist_name"] : '');
        $artist_status   	= intval(isset($params["artist_status"]) ? $params["artist_status"] : 0);
		
        //数据验证
        $Validate = validate('Mcn', 'validate\mcn');
        if( !$Validate -> scene('add_artist') -> check($params) ){
            json_out(-1001, $Validate -> getError());//验证失败
        }
        
		//逻辑处理
        $list = controller('Mcnlogic', 'logic\mcn') -> add_artist($uid, $artist_mobile, $artist_name, $artist_status);

        //数据返回
        if($list['code'] == 200){
            json_out(200, '添加成功');      
        }else{
            json_out($list['code'], $list['message']);      
        }  
	}
	
	/**
     * 编辑艺人信息
     * @author shiqiang<976162041@qq.com>
     * @return mixed
     */
	public function edit_artist(){
		 //参数接收
        $params 			= $this->getParams(1);//0 get 1 post 
        $uid    			= intval(isset($params["user_id"]) ? $params["user_id"] : 0);
        $artist_name   		= isset($params["artist_name"]) ? $params["artist_name"] : '';
        $artist_status   	= intval(isset($params["artist_status"]) ? $params["artist_status"] : 0);
		
        //数据验证
        $Validate = validate('Mcn', 'validate\member');
        if( !$Validate -> scene('edit_artist') -> check($params) ){
            json_out(-1001, $Validate -> getError());//验证失败
        }
		
		//逻辑处理
        $list = controller('Mcnlogic', 'logic\user') -> edit_artist($uid, $artist_id, $artist_mobile, $artist_name, $artist_status);

        ///数据返回
        if($list['code'] == 200){
            json_out(200, '编辑成功');      
        }else{
            json_out($list['code'], $list['message']);      
        }  
	}
	
	/**
     * 删除艺人
     * @author shiqiang<976162041@qq.com>
     * @return mixed
     */
	public function delete_artist(){
		 //参数接收
        $params 			= $this->getParams(1);//0 get 1 post 
        $uid    			= intval(isset($params["user_id"]) ? $params["user_id"] : 0);
        $artist_id	   		= intval(isset($params["artist_id"]) ? $params["artist_id"] : 0);
		
        //数据验证
        $Validate = validate('Mcn', 'validate\mcn');
        if( !$Validate -> scene('delete_artist') -> check($params) ){
            json_out(-1001, $Validate -> getError());//验证失败
        }
		
		//逻辑处理
        $list = controller('Mcnlogic', 'logic\mcn') -> delete_artist($uid, $artist_id);

        //数据返回
        if($list['code'] == 200){
            json_out(200, '删除成功');      
        }else{
            json_out($list['code'], $list['message']);      
        }  
	}
	
	/**
     * 艺人详情
     * @author shiqiang<976162041@qq.com>
     * @return mixed
     */
	public function get_artist_info(){
		 //参数接收
        $params 			= $this->getParams(1);//0 get 1 post 
        $uid    			= intval(isset($params["user_id"]) ? $params["user_id"] : 0);
        $artist_id	   		= intval(isset($params["artist_id"]) ? $params["artist_id"] : 0);
		
        //数据验证
        $Validate = validate('Mcn', 'validate\mcn');
        if( !$Validate -> scene('get_artist_info') -> check($params) ){
            json_out(-1001, $Validate -> getError());//验证失败
        }
		
		//逻辑处理
        $list = controller('Mcnlogic', 'logic\user') -> get_artist_info($uid, $artist_id);

        ///数据返回
        if($list['code'] == 200){
            json_out(200, '获取成功');      
        }else{
            json_out($list['code'], $list['message']);      
        }  
	}
}
